package com.my12306.user.controller;


import com.my12306.common.util.PageUtils;
import com.my12306.common.util.response.ResponseData;
import com.my12306.user.model.po.PThirdEntity;
import com.my12306.user.service.PThirdService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 第三方登录认证表
 *
 * @Author:苏牧夕
 * @Date:2020-05-15 17:36:13
 * @Version 1.0
 */
@RestController
@RequestMapping("user/pthird")
@Api(value = "第三方接口", tags = "第三方接口")
public class PThirdController {
    @Autowired
    private PThirdService pThirdService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("article:pthird:list")
    public ResponseData list(@RequestParam Map<String, Object> params) {
        PageUtils page = pThirdService.queryPage(params);

        return ResponseData.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("article:pthird:info")
    public ResponseData info(@PathVariable("id") Long id) {
        PThirdEntity pThird = pThirdService.getById(id);

        return ResponseData.ok().put("pThird", pThird);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("article:pthird:save")
    public ResponseData save(@RequestBody PThirdEntity pThird) {
        pThirdService.save(pThird);

        return ResponseData.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    //@RequiresPermissions("article:pthird:update")
    public ResponseData update(@RequestBody PThirdEntity pThird) {
        pThirdService.updateById(pThird);

        return ResponseData.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    //@RequiresPermissions("article:pthird:delete")
    public ResponseData delete(@RequestBody Long[] ids) {
        pThirdService.removeByIds(Arrays.asList(ids));

        return ResponseData.ok();
    }

}
